package com.five.bi.config;

import com.five.bi.interceptor.CrosInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    CrosInterceptor crosInterceptor(){
        return new CrosInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 拦截全部路径，解决浏览器跨域的问题
         */
        registry.addInterceptor(crosInterceptor()).addPathPatterns("/**");
    }
}
